<?php
	class controller{
		public function renderView($option){
			try {
				if(array_key_exists("params", $option)){
					systemGlobals::$viewParameters = $option['params'];
				}else{
					systemGlobals::$viewParameters="";
				}
				systemGlobals::checkContent('system/'.systemGlobals::$module.'/view/'.systemGlobals::$folder.'/'.$option['view'].'.php');
				include_once 'system/'.systemGlobals::$module.'/view/'.systemGlobals::$folder.'/'.$option['view'].'.php';
			} catch (Exception $e) {
				$error = new errorHandler();
				echo $error->error404();
			}
			return null;
		}
		// redirect with parent.
		public function redirect($request){
			$data = explode("/", $request);
			$length = count($data);
			$newRequest = "";
				if($length==1){
					if(systemGlobals::$moduleName){
						$newRequest .=systemGlobals::$moduleName."/";
					}
					$newRequest .= systemGlobals::$folder."/".$request;
				}else if($length==2){
				if(systemGlobals::$moduleName){
						$newRequest .=systemGlobals::$moduleName."/";
					}
				$newRequest.=$request;
				}else{
					$newRequest = $request;
				}
				header("Location:index.php?r=".$newRequest);
		}
	}